package cn.coisini.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author xiangshaw
 * Description:
 */
// 标识为配置类
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${file.upload.local.path}")
    private String uploadPath;

    // 静态资源映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将访问路径 /images/** 映射到本地路径 uploadPath
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:" + uploadPath);
    }

}
